home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htpasswd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  4.7 KB  |  128 lines

  1. /*                                   PASSWORD FILE ROUTINES
  2.                                              
  3.  */
  4.  
  5. #ifndef HTPASSWD_H
  6. #define HTPASSWD_H
  7.  
  8. #include "HTUtils.h"
  9. #include "HTList.h"
  10.  
  11. #ifdef SHORT_NAMES
  12. #define HTAAenPw        HTAA_encryptPasswd
  13. #define HTAApwMa        HTAA_passwdMatch
  14. #define HTAAFrPR        HTAAFile_readPasswdRec
  15. #define HTAAchPw        HTAA_checkPasswd
  16. #endif /* SHORT_NAMES */
  17.  
  18. /*
  19.  
  20. User Authentication
  21.  
  22.    HTAA_checkPassword(username,password,passwdfile)opens the password file, and checks if
  23.    the username-password pair is correct. Return value is YES, if and only if they are
  24.    correct. Otherwise, and also if the open fails, returns NO.
  25.    
  26.    If the given password file name is NULL or an empty string, the default password file
  27.    name is used (macro PASSWD_FILE).
  28.    
  29.  */
  30.  
  31. /* PUBLIC                                               HTAA_checkPassword()
  32. **                      VALIDATE A USERNAME-PASSWORD PAIR
  33. ** ON ENTRY:
  34. **      username        is a null-terminated string containing
  35. **                      the client's username.
  36. **      password        is a null-terminated string containing
  37. **                      the client's corresponding password.
  38. **      filename        is a null-terminated absolute filename
  39. **                      for password file.
  40. **                      If NULL or empty, the value of
  41. **                      PASSWD_FILE is used.
  42. ** ON EXIT:
  43. **      returns         YES, if the username-password pair was correct.
  44. **                      NO, otherwise; also, if open fails.
  45. */
  46. PUBLIC BOOL HTAA_checkPassword PARAMS((CONST char * username,
  47.                                        CONST char * password,
  48.                                        CONST char * filename));
  49. /*
  50.  
  51. Password File Maintenance Routines
  52.  
  53.  */
  54.  
  55. /* PUBLIC                                               HTAA_encryptPasswd()
  56. **              ENCRYPT PASSWORD TO THE FORM THAT IT IS SAVED
  57. **              IN THE PASSWORD FILE.
  58. ** ON ENTRY:
  59. **      password        is a string of arbitrary lenght.
  60. **
  61. ** ON EXIT:
  62. **      returns         password in one-way encrypted form.
  63. **
  64. ** NOTE:
  65. **      Uses currently the C library function crypt(), which
  66. **      only accepts at most 8 characters long strings and produces
  67. **      always 13 characters long strings. This function is
  68. **      called repeatedly so that longer strings can be encrypted.
  69. **      This is of course not as safe as encrypting the entire
  70. **      string at once, but then again, we are not that paranoid
  71. **      about the security inside the machine.
  72. **
  73. */
  74. PUBLIC char *HTAA_encryptPasswd PARAMS((CONST char * password));
  75.  
  76.  
  77. /* PUBLIC                                               HTAA_passwdMatch()
  78. **              VERIFY THE CORRECTNESS OF A GIVEN PASSWORD
  79. **              AGAINST A ONE-WAY ENCRYPTED FORM OF PASSWORD.
  80. ** ON ENTRY:
  81. **      password        is cleartext password.
  82. **      encrypted       is one-way encrypted password, as returned
  83. **                      by function HTAA_encryptPasswd().
  84. **                      This is typically read from the password
  85. **                      file.
  86. **
  87. ** ON EXIT:
  88. **      returns         YES, if password matches the encrypted one.
  89. **                      NO, if not, or if either parameter is NULL.
  90. */
  91. PUBLIC BOOL HTAA_passwdMatch PARAMS((CONST char * password,
  92.                                      CONST char * encrypted));
  93.  
  94.  
  95. /* PUBLIC                                               HTAAFile_readPasswdRec()
  96. **                      READ A RECORD FROM THE PASSWORD FILE
  97. ** ON ENTRY:
  98. **      fp              open password file
  99. **      out_username    buffer to put the read username, must be at
  100. **                      least MAX_USERNAME_LEN+1 characters long.
  101. **      out_passwd      buffer to put the read password, must be at
  102. **                      least MAX_PASSWORD_LEN+1 characters long.
  103. ** ON EXIT:
  104. **      returns         EOF on end of file,
  105. **                      otherwise the number of read fields
  106. **                      (i.e. in a correct case returns 2).
  107. **      out_username    contains the null-terminated read username.
  108. **      out_password    contains the null-terminated read password.
  109. **
  110. ** FORMAT OF PASSWORD FILE:
  111. **      username:password:maybe real name or other stuff
  112. **                              (may include even colons)
  113. **
  114. **      There may be whitespace (blanks or tabs) in the beginning and
  115. **      the end of each field. They are ignored.
  116. */
  117. PUBLIC int HTAAFile_readPasswdRec PARAMS((FILE * fp,
  118.                                           char * out_username,
  119.                                           char * out_password));
  120. /*
  121.  
  122.  */
  123.  
  124. #endif /* not HTPASSWD_H */
  125. /*
  126.  
  127.    End of file HTPasswd.h.  */
  128.